<template>
  <div class="carousel flex-col-start">

    <el-empty description="暂无图片" class="carousel-image" v-if="list.length === 0">暂时没有图片</el-empty>
    <el-image fit="cover" class="carousel-image" :src="list[active]" v-else>

    </el-image>
    <div class="carousel-list flex-row-around">
      <div class="flex-row-start" style="width: 100%">

          <el-image v-for="(image,index) in list"
                    fit="cover"
                    :class="[computedActiveClass(index),'carousel-image-item',]"
                    @click="active=index"
                    :src="image"
          ></el-image>

      </div>

    </div>
  </div>
</template>

<script>
export default {
  name: "Carousel",
  props:{
    list:{
      type:String
    }
  },
  data() {
    return {
        active:0
    }
  },
  methods: {},
  computed:{
    computedActiveClass(){

      return (index)=>{
        return index === this.active?'active':'inactive'
      }
    }
  }
}
</script>

<style scoped lang="less">
  .carousel{
    width: 750px;
    .carousel-image{
      width: 750px;
      height: 450px;
    }
    .carousel-list{
      width: 100%;
      margin-top: 10px;
      .carousel-image-item{
        cursor: pointer;
        border-radius: 3px;
        width: 100px;
        height: 100px;
        margin-right: 10px;
      }
      .active{
        opacity: 1;
      }
      .inactive{
        opacity: 0.4;
      }
    }

  }
</style>